package com.xzm.project.ui.fragment.tab;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xzm.project.R;
import com.xzm.project.ui.adapter.DemoItemAdapter;
import com.xzm.project.ui.bean.DemoItem;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class FragmentThree extends Fragment {
    TextView textView;
    private DemoItemAdapter mAdapter;
    private RecyclerView recyclerViewDemoItem;

    public static FragmentThree newInstance(String text) {
        FragmentThree fragmentCommon = new FragmentThree();
        Bundle bundle = new Bundle();
        bundle.putString("text", text);
        fragmentCommon.setArguments(bundle);
        return fragmentCommon;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_three, container, false);
//        textView= (TextView) view.findViewById(R.id.textView);
//        textView.setText(getArguments().getString("text"));
        initView(view);
        initDates();
        return view;
    }

    private void initView(View view) {
        recyclerViewDemoItem = view.findViewById(R.id.recyclerView_demo_item);
        recyclerViewDemoItem.setLayoutManager(new GridLayoutManager(getContext(), 2));
        TextView textView = view.findViewById(R.id.tv_toolbaer_title);
        textView.setText(getArguments().getString("text"));
    }

    public void initDates() {
        mAdapter = new DemoItemAdapter();
        mAdapter.openLoadAnimation();
        recyclerViewDemoItem.setHasFixedSize(true);
        recyclerViewDemoItem.setAdapter(mAdapter);
        addBaseDate();
    }

    private void addBaseDate() {
//        mlist.add(new DemoItem(ZhiHuBehaviorActivity.class, "模仿知乎Behavior"));
        mAdapter.notifyDataSetChanged();
    }
}
